Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples of how to use ethpm for contract factories/instances #1617

Merged

Conversation

njgheorghita
Copy link
Contributor

@njgheorghita njgheorghita commented Mar 30, 2020

What was wrong?

Moar docs! Particularly how to use ethpm to create contract instances / factories.

Fixes #1611

Todo:

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@njgheorghita
Copy link
Contributor Author

njgheorghita commented Mar 30, 2020

@kclowes Let me know if there's something that's not obvious - or needs further explaining - or needs more exampling. It's a bit hard for me to see where I overlooked explaining something that newcomers might not understand intuitively.

Copy link
Collaborator

@kclowes kclowes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀 Thank you!

within a package, and exposes them via an API. So, before we can interact with our package, we need to generate
it as a ``Package`` instance.

.. code-block:: python3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think its possible/worth making these doctests?

Copy link
Contributor Author

@njgheorghita njgheorghita Mar 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it's possible - do you know if we have an infura key loaded in the doctest environment? EDIT: nvm I think I found it - i'll look into transforming these to doctest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: I've been having some troubles getting this test to work with doctest - so I'm gonna move on for now. I don't think it's impossible, but it's been tricky getting all the pieces to work, but i'm happy to dedicate more time to this if it's important for web3's sake to have consistent doctests amongst the examples - just let me know if you'd like it to be doctested and i'll add it to my todo list!

Working with Contracts via ethPM
--------------------------------

`ethPM <http://www.ethpm.com/>`__ packages contained configured contracts ready for use. Web3's ``ethpm`` module (``web3.pm``)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`ethPM <http://www.ethpm.com/>`__ packages contained configured contracts ready for use. Web3's ``ethpm`` module (``web3.pm``)
`ethPM <http://www.ethpm.com/>`__ packages contain configured contracts ready for use. Web3's ``ethpm`` module (``web3.pm``)

# deploy to this new chain, and the deployments available on a package will
# be automatically filtered to those located on the new chain.
from web3.auto.infura.goerli import w3 as goerli_w3
goerli_registrar = ens_package.update_w3(goerli_w3)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooo, that's cool!

extends Web3's native ``Contract`` module, with a few modifications for how you instantiate ``Contract`` factories and instances.

All you need is the package name, version and ethPM registry address for the package you wish to use.
You can find some available registries to explore in the `ethPM explorer <http://explorer.ethpm.com/>`__.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth a quick explanation of what a registry is in this context unless it's already explained elsewhere

@njgheorghita njgheorghita merged commit 79aba6d into ethereum:master Mar 31, 2020
@njgheorghita njgheorghita deleted the contract-instantiation-examples branch March 31, 2020 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document manual contract instantiation vs ethpm
2 participants